package com.ruoyi.project.manage.controller;

import com.ruoyi.framework.web.domain.AjaxResult;

import com.ruoyi.project.manage.SavePrescriptionVO;
import com.ruoyi.project.manage.service.HisSaveCaseService;
import com.ruoyi.project.manage.service.HisSaveCaseService;
import com.ruoyi.project.manage.service.impl.HisSaveCaseImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/manage/check")
public class HisSavecaseController {
    @Autowired
    public HisSaveCaseService hisSaveCaseService;

    @PreAuthorize("@ss.hasPermi('manage:check:index')")
    @GetMapping("/export")
    public AjaxResult export( Long sRegistrationFormId,Integer checkModel) {
        Map<String,Object>  map = new HashMap<>();
        try {

            List<SavePrescriptionVO>  one = hisSaveCaseService.findOne(sRegistrationFormId,checkModel);
            map.put("code",0);
            map.put("msg","ok");
            map.put("data",one);
            return AjaxResult.success(map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        map.put("code",-1);
        map.put("msg","查询失败");
        return AjaxResult.success(map);
    }

    //新开检查
    @PreAuthorize("@ss.hasPermi('manage:check:index')")
    @PostMapping("/beginCheck")
    public AjaxResult beginCheck(Integer aid) {
        Map<String, Object> dataMap = new HashMap<>();
        try {
            boolean b  = hisSaveCaseService.updateSatus(aid);
            if (b){
                dataMap.put("code",0);
                dataMap.put("msg","ok");
            }else {
                dataMap.put("code",-1);
                dataMap.put("msg","修改失败");
            }
            return AjaxResult.success(dataMap);
        } catch (Exception e) {
            e.printStackTrace();
        }
        dataMap.put("code",-1);
        dataMap.put("msg","修改失败");
        return  AjaxResult.success(dataMap);
    }

    /*//检查结果录入查询
    @PreAuthorize("@ss.hasPermi('system:look:index')")
    @GetMapping("")
    public AjaxResult quaersd(String registrationid){
        Map<String, Object> one02 = saveCase.findOne02(registrationid);

        return AjaxResult.success(one02);

    }*/
}
